<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>五、Tree（树）</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">

		<jsp:include page="../basic/easyui_loder.jsp" flush="true"/>
		
		<script type="text/javascript">
			$(document).ready(function(){
				$("#tree").tree({
					data: [{
						text: '主目录',
						state: 'closed'
					}],
					onSelect: function(selectNode){
						console.log("select: " + selectNode.id);
					}
				});
				
				$.ajax({
					type : "POST",
					dataType : "json",
					url : "testAction_loadTree",
					success : function(data){
						var rootNode = $("#tree").tree('getRoot');
						/* 向root添加子节点 */
						$("#tree").tree('append',{
							parent: rootNode.target,
							data: data
						});
						
						/* 展开所有节点 */
						$("#tree").tree('expandAll');
						
						var children = $("#tree").tree('getChildren',rootNode.target);
						
						/* 选中第一个子节点 */
						$("#tree").tree("select",children[0].target);
					}
				});
			});
		</script>

	</head>

	<body>
		<hr/>
		<h2>Tree（树）</h2>
		
		<ul id="tree">
		</ul>
		
		
		<br/><br/>
	</body>
</html>
